/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package RoomPanel;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author 52194291
 */
public class RoomPanel extends HttpServlet {

    /**
     * Processes requests for both HTTP
     * <code>GET</code> and
     * <code>POST</code> methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     * 
     * url: https://cs4280gp.googlecode.com/svn/trunk
     * ac:  raytang10.4@gmail.com
     * pw:  mV8Dr2kS5ZM9
     */
    
    private static HttpSession session;
    
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        session = request.getSession(true);
        try {
            /*
             * TODO output your page here. You may use following sample code.
             */
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet RoomPanel</title>");  
            
            out.println("<style type=\"text/css\">");
            out.println(".frame{height:90%;overflow-x:hidden;overflow-y:hidden;visibility:'hidden';}");
            out.println("#infoWindow{width:500px;}");
            out.println("#matchWindow{width:500px;}");
            out.println("#logout{height:100%;}");
            out.println("#header{color:WHITE;}");
            out.println("body{background-image:url('http://db.tt/HJgFAj3U');}");
            out.println(".menuStyle{width:100px;height:30px;font-size:30px;background:BLACK;color:White;}");
            out.println("</style>");
            
            out.println("<script type=\"text/javascript\">");
            out.println("function dropDown(){document.getElementById('menu').style.visibility = 'visible';}");
            out.println("function clicked(id){");
            out.println("   document.getElementById(id+'window').style.visibility = 'visible';");
            out.println("   document.getElementById('menu').style.visibility = 'hidden';");
            out.println("}");
            out.println("function toOpen(id){document.getElementById(id).style.visibility = 'visible';}");
            out.println("function toClose(id){document.getElementById(id).style.visibility = 'hidden';}");
            out.println("</script>");
        
            out.println("</head>");
            out.println("<body>");
            out.println("<div id=\"header\" style=\"background-color:RED;\">");
            out.println("   <h1 style=\"float:left;background-color:RED;\">Football Manager</h1>");
            out.println("   <h1 style=\"float:right;background-color:RED;\" onmouseover=\"dropDown()\">Menu</h1>");
            out.println("</div>");
            out.println("<br /><br />");
            
            out.println("<div id=\"menu\" style=\"float:right;visibility:'hidden';color:ORANGE;\">");
            out.println("<p class=\"menuStyle\" id=\"info\" onclick=\"clicked(this.id)\">My Info</p>");
            out.println("<p class=\"menuStyle\" id=\"match\" onclick=\"clicked(this.id)\">Matches</p>");
            out.println("<p class=\"menuStyle\" id=\"shop\" onclick=\"clicked(this.id)\">Shop</p>");
            out.println("</div>");
            
            out.println("<iframe src=\"userInfo\" id=\"infoWindow\" class=\"frame\"></iframe>");
            out.println("<input type=\"button\" id=\"infoWindowX\" value=\"-\" onclick=\"toClose('infoWindow')\"/>");
            out.println("<input type=\"button\" id=\"infoWindowO\" value=\"o\" onclick=\"toOpen('infoWindow')\"/>");
            out.println("<iframe src=\"GameRoomPanel\" id=\"matchWindow\" class=\"frame\"></iframe>");
            out.println("<input type=\"button\" id=\"matchWindowX\" value=\"-\" onclick=\"toClose('matchWindow')\"/>");
            out.println("<input type=\"button\" id=\"matchWindowO\" value=\"o\" onclick=\"toOpen('matchWindow')\"/>");
            out.println("<iframe src=\"StorePage\" id=\"displayWindow\" class=\"frame\"></iframe>");
            out.println("<input type=\"button\" id=\"StorePage\" value=\"-\" onclick=\"toClose('StorePage')\"/>");
            out.println("<input type=\"button\" id=\"StorePage\" value=\"o\" onclick=\"toClose('StorePage')\"/>");
            /*
            out.println("<iframe src=\"userInfo\" id=\"userInfo\" class=\"frame\"></iframe>");
            out.println("<iframe src=\"GameRoomPanel\" id=\"gameRoom\" class=\"frame\"></iframe>");
            out.println("<iframe src=\"\" id=\"temp2\" class=\"frame\" style=\"height:50%;\"></iframe>");
            */
            //out.println("<a href=\"\" id=\"logout\">LOGOUT</a>");
            out.println("</body>");
            out.println("</html>");
        } finally {            
            out.close();
        }
    }
    
    public static HttpSession getSession(){return session;}

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP
     * <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP
     * <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}
